// dynamic.cpp : Defines the exported functions for the DLL application.
//

#include <Windows.h>
#include <new> // for placement new
#include <crtdbg.h>
#include <ObjBase.h>
#include "ConsoleDll.h"


extern "C" {
// This is an example of an exported variable
CONSOLEDLL_API int ndynamic = 0;

// This is an example of an exported function.

void SimpleLeak_Malloc(void)
{
	int* leaked_memory = NULL;
	int* leaked_memory_dbg = NULL;
	leaked_memory     = (int*)malloc(78);
	leaked_memory_dbg = (int*)_malloc_dbg(80, _NORMAL_BLOCK,__FILE__,__LINE__);
}

void SimpleLeak_New(void)
{
	int* leaked_memory = NULL;
	int* leaked_memory_dbg = NULL;
	leaked_memory = new int(4);
	leaked_memory_dbg = new (_NORMAL_BLOCK, __FILE__, __LINE__) int(7);
}

void SimpleLeak_New_Array(void)
{
	int* leaked_memory = NULL;
	int* leaked_memory_dbg = NULL;
	leaked_memory = new int[3];
	leaked_memory_dbg = new (_NORMAL_BLOCK,__FILE__,__LINE__) int[4];

	// placement new operator
	int temp[3];
	void* place = temp;
	float* placed_mem = new (place) float[3]; // doesn't work. Nothing gets patched by vld

}

// This is the constructor of a class that has been exported.
// see dynamic.h for the class definition
CConsoleDll::CConsoleDll()
{
	return;
}

}